package cz.boxdesign.library.web.validation;

import javax.validation.Validation;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import cz.boxdesign.library.web.view.BookView;


public class BookValidator implements Validator {

  @Override
  public boolean supports(Class<?> clazz) {
    return clazz == BookView.class;
  }

  @Override
  public void validate(Object target, Errors errors) {
	    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "nazev", "field.required");
	    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "pocetKnih", "field.required");
	    ValidationUtils.rejectIfEmptyOrWhitespace(errors,"rokVydani" , "field.required");
	    ValidationUtils.rejectIfEmpty(errors, "nakladatelstviId", "field.required");
	    ValidationUtils.rejectIfEmpty(errors, "autorIds", "field.required");
	    ValidationUtils.rejectIfEmpty(errors, "oddeleniId", "field.required");

  }

}
